<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改历史解释')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-lishi-edit" th:object="${cizuLishi}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">词语：</label>
                <div class="col-sm-8">
                    <input name="ci" th:field="*{ci}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <input name="type" th:field="*{type}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">解释：</label>
                <div class="col-sm-8">
                    <input id="jieshi" name="jieshi" th:field="*{jieshi}" type="hidden">
                    <div id="editor-jieshi" class="summernote"></div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script src="/js/standalone.js"></script>
    <script src="/js/parser-html.js"></script>
    <script type="text/javascript">
        var prefix = ctx + "dict/lishi";
        $("#form-lishi-edit").validate({
            focusCleanup: true
        });


        function prettierFormat(html) {
            try{
                if(prettier == null || prettierPlugins == null) {
                  return html;
                }
                return prettier.format(html, {
                  parser: "html",
                  plugins: prettierPlugins
                });
            }catch(error){
               return html;
            }
        }

        $(function() {
		    $('.summernote').summernote({
		    	placeholder: '请输入内容',
		    	height : 400,
				lang : 'zh-CN',
				followingToolbar: false,
				callbacks: {
	                onImageUpload: function (files) {

	                }
	            }
		    });
		    $('#editor-jieshi').summernote('code', prettierFormat($("#jieshi").val()));
	    });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-lishi-edit').serialize());
            }
        }

    </script>
</body>
</html>